package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DagPerformance;
import com.ruoyi.system.service.IDagPerformanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * DAG性能评测Controller
 * 
 * @author NovaTian
 * @date 2022-05-12
 */
@RestController
@RequestMapping("/system/performance")
public class DagPerformanceController extends BaseController
{
    @Autowired
    private IDagPerformanceService dagPerformanceService;

    /**
     * 查询DAG性能评测列表
     */
    @PreAuthorize("@ss.hasPermi('system:performance:list')")
    @GetMapping("/list")
    public TableDataInfo list(DagPerformance dagPerformance)
    {
        startPage();
        List<DagPerformance> list = dagPerformanceService.selectDagPerformanceList(dagPerformance);
        return getDataTable(list);
    }

    /**
     * 导出DAG性能评测列表
     */
    @PreAuthorize("@ss.hasPermi('system:performance:export')")
    @Log(title = "DAG性能评测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DagPerformance dagPerformance)
    {
        List<DagPerformance> list = dagPerformanceService.selectDagPerformanceList(dagPerformance);
        ExcelUtil<DagPerformance> util = new ExcelUtil<DagPerformance>(DagPerformance.class);
        util.exportExcel(response, list, "DAG性能评测数据");
    }

    /**
     * 获取DAG性能评测详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:performance:query')")
    @GetMapping(value = "/{uuid}")
    public AjaxResult getInfo(@PathVariable("uuid") String uuid)
    {
        return AjaxResult.success(dagPerformanceService.selectDagPerformanceByUuid(uuid));
    }

    /**
     * 新增DAG性能评测
     */
    @PreAuthorize("@ss.hasPermi('system:performance:add')")
    @Log(title = "DAG性能评测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DagPerformance dagPerformance)
    {
        return toAjax(dagPerformanceService.insertDagPerformance(dagPerformance));
    }

    /**
     * 修改DAG性能评测
     */
    @PreAuthorize("@ss.hasPermi('system:performance:edit')")
    @Log(title = "DAG性能评测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DagPerformance dagPerformance)
    {
        return toAjax(dagPerformanceService.updateDagPerformance(dagPerformance));
    }

    /**
     * 删除DAG性能评测
     */
    @PreAuthorize("@ss.hasPermi('system:performance:remove')")
    @Log(title = "DAG性能评测", businessType = BusinessType.DELETE)
	@DeleteMapping("/{uuids}")
    public AjaxResult remove(@PathVariable String[] uuids)
    {
        return toAjax(dagPerformanceService.deleteDagPerformanceByUuids(uuids));
    }
}
